package com.dinzeer.slashblade_useful_addon.mixin;

import com.aetherteam.aether.entity.monster.dungeon.boss.SunSpirit;
import mods.flammpfeil.slashblade.entity.Projectile;
import mods.flammpfeil.slashblade.item.ItemSlashBlade;
import net.minecraft.world.damagesource.DamageSource;
import net.minecraft.world.entity.player.Player;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin({SunSpirit.class})
public abstract class SunSpriltMixin {


    @Inject(
            method ={ "isInvulnerableTo"},
            at ={ @At("HEAD")},
            cancellable = true,
            remap = true
    )
    private void onIsInvulnerableTo(DamageSource source, CallbackInfoReturnable<Boolean> cir) {

        if (source.getDirectEntity() instanceof Projectile sources){
            if (sources.getOwner() instanceof Player player) {
                if(player.getMainHandItem().getItem() instanceof ItemSlashBlade){
                    cir.setReturnValue(false);
                }
            }
        }
           if(source.getDirectEntity() instanceof Player player) {
                if(player.getMainHandItem().getItem() instanceof ItemSlashBlade){
                   cir.setReturnValue(false);
                }



           }
    }
}